package net.xiezihao.fuxiclient.demo.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.logging.Handler;

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private MyFeignClient feignClient;
    @Override
    public Object getProject(int id) {
        Object object = restTemplate.getForObject("http://product-service/api/v1/product/find?id=" + id, Object.class);
        System.out.println(object);
        return object;
    }

    @Override
    public Object getProjectByFeign(int id) {
        String client = feignClient.findById(id);
        String user = feignClient.getUser();
        System.out.println(client);
        System.out.println(user);
        HashMap<Object, Object> map = new HashMap<>();
        map.put("user",user);
        map.put("project",client);
        return map;
    }
}
